<?php
/**
 * Script used to fetch all data from a spesific project, and also fetch the
 * external user's name that matches the project's owner.
 */

// Start the session handling system
session_start ();

// Connect to the database
require_once ("../../db.php");

$sql =
'SELECT p.*, e.companyname
FROM projects p, externalusers e
WHERE p.id='.$_POST['pid'].' AND p.owner = e.id';

$sth = $db->prepare($sql);
$sth->execute();
$row = $sth->fetchAll();

if ($row) echo json_encode($row);
else      echo json_encode(array('error' => 'The project does not exist.'));

?>